<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/7/26
 * Time: 15:21
 */

namespace app\common\validate;


use think\Validate;

class Order extends Validate
{
    protected $rule = [
        'order_time|预约时间'  =>  'require|checkDate',
        'content|评价'  =>  'require|max:50',
        'score|评分'  =>  'require|between:1,5',
        'apply_id|邀约技能'  =>  'require',
        'to_user|下单用户'  =>  'require',
        'remark|下单备注'  =>  'max:100',
        'price|下单金额'  =>  'require|number',
        'anonymous|匿名评价'  =>  'in:1,0',
        'id|订单'  =>  'require|number',
    ];

    protected $scene = [
        'add'=> ['order_time','apply_id','to_user','remark','price'],
        'edit'=> ['cid'],
        'evaluate'=> ['content','score','id'],
    ];
    protected function checkDate($value)
    {

        if (!is_numeric($value)) return '时间格式错误';

//        if ($value < time()+60*30) return '预约时间需大于当前时间30分钟以上';

        return true;

    }


}